<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
    <title>Document</title>
</head>

<body>
    <script>
        
        window.addEventListener("beforeunload", function (e) {
        
          var confirmationMessage = '确定离开此页吗？本页不需要刷新或后退';
        
         
        
          (e || window.event).returnValue = confirmationMessage;     // Gecko and Trident
        
          return confirmationMessage;                                // Gecko and WebKit
        
        });
    </script>
</body>

</html>